<?php

/**
 * user form base class.
 *
 * @method user getObject() Returns the current form's model object
 *
 * @package    pendidikan indonesia
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseuserForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'nama'            => new sfWidgetFormInputText(),
      'tempat_lahir'    => new sfWidgetFormInputText(),
      'tanggal_lahir'   => new sfWidgetFormDateTime(),
      'alamat'          => new sfWidgetFormInputText(),
      'id_kota'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('setKota'), 'add_empty' => true)),
      'id_propinsi'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('setPropinsi'), 'add_empty' => true)),
      'id_sekolah'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sekolah'), 'add_empty' => true)),
      'email'           => new sfWidgetFormInputText(),
      'id_bidang_studi' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('setBidangStudi'), 'add_empty' => true)),
      'id_profesi'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('setProfesi'), 'add_empty' => true)),
      'is_public'       => new sfWidgetFormInputCheckbox(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'nama'            => new sfValidatorString(array('max_length' => 100)),
      'tempat_lahir'    => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'tanggal_lahir'   => new sfValidatorDateTime(array('required' => false)),
      'alamat'          => new sfValidatorPass(array('required' => false)),
      'id_kota'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('setKota'), 'required' => false)),
      'id_propinsi'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('setPropinsi'), 'required' => false)),
      'id_sekolah'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sekolah'), 'required' => false)),
      'email'           => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'id_bidang_studi' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('setBidangStudi'), 'required' => false)),
      'id_profesi'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('setProfesi'), 'required' => false)),
      'is_public'       => new sfValidatorBoolean(array('required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'user', 'column' => array('email')))
    );

    $this->widgetSchema->setNameFormat('user[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'user';
  }

}
